#ifndef _DBMANAGER_H_
#define _DBMANAGER_H_



#include "GamePlayer.h"
#include "GamePet.h"
#include "GameDB.h"


class DBManager
{
public:

	static const fbyte* GetPlayerDBData( GamePlayer* player )
	{
		// 0 map id
		// 1 x
		// 2 y

		// 3 level 
		// 4 level pro
		// 5 level up point
		// 6 exp
		// 7 vitality
		// 8 strength
		// 9 toughness
		// 10 dexterity
		// 11 charm
		// 12 hp
		// 13 mp
		// 14 role
		// 15 color
		// 16 Eye
		// 17 Mouth
		// 18 earth
		// 19 water
		// 20 fire
		// 21 wind

		// 22 stone

		CreatureMoveData& moveData = player->GetMoveData();
		CreatureData& data = player->GetData();
		CreatureFightData& fightData = player->GetFightData();
		
		static fbyte c[ MAX_SQL_BUFFER ];
		SPRINTF( c , "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,,,,,,,,,,,,," ,
			moveData.Pos.MapID , moveData.Pos.Grid.x , moveData.Pos.Grid.y , 
			data.Level , data.LevelPRO , data.LevelUpPoint ,
			data.EXP ,
			data.Vitality , data.Strength , data.Toughness , data.Dexterity , 
			data.Base.Charm ,
			fightData.Base.HP , fightData.Base.MP ,
			data.Role , data.Color , data.Eye , data.Mouth ,
			data.Base.Earth , data.Base.Water , data.Base.Fire , data.Base.Wind , 
			player->mStone );
		
		return c;
	}

	static const fbyte* GetItemDBData( GamePlayer* player )
	{
		ItemBag& bag = player->GetItemBag();

		static fbyte c[ MAX_SQL_BUFFER ];
		SPRINTF( c , "%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,%d|%d,,,,,,,,,,,,,,,," ,
			bag.GetEquip(0).GetID() , bag.GetEquip( 0 ).GetNum() , 
			bag.GetEquip(1).GetID() , bag.GetEquip( 1 ).GetNum() , 
			bag.GetEquip(2).GetID() , bag.GetEquip( 2 ).GetNum() , 
			bag.GetEquip(3).GetID() , bag.GetEquip( 3 ).GetNum() , 
			bag.GetEquip(4).GetID() , bag.GetEquip( 4 ).GetNum() , 
			bag.GetEquip(5).GetID() , bag.GetEquip( 5 ).GetNum() , 
			bag.GetEquip(6).GetID() , bag.GetEquip( 6 ).GetNum() , 
			bag.GetEquip(7).GetID() , bag.GetEquip( 7 ).GetNum() , 
			bag.GetEquip(8).GetID() , bag.GetEquip( 8 ).GetNum() , 
			
			bag.GetItem(0).GetID() , bag.GetItem( 0 ).GetNum() , 
			bag.GetItem(1).GetID() , bag.GetItem( 1 ).GetNum() , 
			bag.GetItem(2).GetID() , bag.GetItem( 2 ).GetNum() , 
			bag.GetItem(3).GetID() , bag.GetItem( 3 ).GetNum() , 
			bag.GetItem(4).GetID() , bag.GetItem( 4 ).GetNum() , 
			bag.GetItem(5).GetID() , bag.GetItem( 5 ).GetNum() , 
			bag.GetItem(6).GetID() , bag.GetItem( 6 ).GetNum() , 
			bag.GetItem(7).GetID() , bag.GetItem( 7 ).GetNum() , 
			bag.GetItem(8).GetID() , bag.GetItem( 8 ).GetNum() , 
			bag.GetItem(9).GetID() , bag.GetItem( 9 ).GetNum() , 
			bag.GetItem(10).GetID() , bag.GetItem( 10 ).GetNum() , 
			bag.GetItem(11).GetID() , bag.GetItem( 11 ).GetNum() , 
			bag.GetItem(12).GetID() , bag.GetItem( 12 ).GetNum() , 
			bag.GetItem(13).GetID() , bag.GetItem( 13 ).GetNum() , 
			bag.GetItem(14).GetID() , bag.GetItem( 14 ).GetNum() );

		return c;
	}



	static const fbyte* GetPetDBData( GamePet* pet )
	{
		// 0 type
		// 1 id
		// 2 level 
		// 3 exp
		// 4 level up point
		// 5 vitality
		// 6 strength
		// 7 toughness
		// 8 dexterity
		// 9 charm
		// 10 hp
		// 11 mp

		PetData& petData = pet->GetPetData();
		CreatureData& data = pet->GetData();
		CreatureFightData& fightData = pet->GetFightData();
		GameEnemy* enemy = pet->GetEnemy();

		static fbyte c[ MAX_SQL_BUFFER ];
		SPRINTF( c , "%d,%d,%d,%d,%.3f,%.3f,%.3f,%.3f,%.3f,%d,%d,%d,,,,,,,,,,,,,,,,,,,,,,,," ,
			fint32( pet->GetPetType() ) , 
			enemy->intValue[ GEIV_ID ] , 
			data.Level , data.EXP , 
			petData.LevelUpPoint , 
			petData.Vitality , petData.Strength , petData.Toughness , petData.Dexterity , 
			data.Base.Charm , 
			fightData.Base.HP , fightData.Base.MP
			);

		return c;
	}
	
// 	CreatureData* GetDBData( const fbyte* data )
// 	{
// 		static CreatureData	cd;
// 
// 		return &cd;
// 	}



protected:
private:

	

};






#endif


